mudbox::Topology Class Reference

#include <topology.h>

Inheritance diagram for mudbox::Topology:

Inheritance graph
[legend]
List of all members.

Detailed Description

The class Mesh is inherited from this class, and provides information about the vertices.

Since only full triangle or quad meshes are allowed in Mudbox, an instance of this class is basically an array of triangles and quads. When a mixed triangle-quad or n-sided mesh is imported into mudbox, then the mesh is converted to a full triangle topology, see the member functions IsFakeTriangle and SetFakeTriangle. The Topology class can hold different type of data for the polygons, like position indices, adjacency, texture coordinate indices etc. These are called face components. To save memory not every buffer is allocated at the beginning. You can control which buffers will be allocated by calling the AddFaceComponent() and RemoveFaceComponent() functions.


Public Types

enum   FaceState {
  fsSelected = 0x01, fsVisible = 0x02, fsFake = 0x04, fsActive = 0x08,
  fsMapped = 0x10
}
enum   FaceComponent {
  fcIndex = 1, fcAdjacency = 2, fcTCIndex = 4, fcNormal = 8,
  fcID = 16, fcOctree = 32, fcFreeze = 64, fcState = 128
}
enum   FaceType { typeTriangular, typeQuadric }

Public Member Functions

void  MoveTo (Topology *pDestination)
  This object will loose all data and become an empty topology.
void  CopyTo (Topology *pDestination) const
  This function is similar to MoveTo, but since it is copying all the data, it is slower.
void  Serialize (Stream &s)
  serializes the content of the object into/from a stream.
FaceType  Type (void) const
  Returns the type of the topology. Can be full triangular or full quadric.
void  SetType (FaceType eType)
  Sets the type of the object. This call also clears all the content of the object.
int  SideCount (void) const
  Returns the number of sides in the faces. This is three if the topology is triangle based, and four if its quad based.
unsigned int  FaceCount (void) const
  Returns the number of faces in the topology.
virtual Vector  FaceNormal (unsigned int iFaceIndex) const
  Returns the normal vector for a face in the topology.
void  SetFaceID (unsigned int iFaceIndex, unsigned int iID)
  This function is used only internally.
unsigned int  FaceID (unsigned int iFaceIndex) const
  This function is used only internally.
virtual void  SetFakeTriangleCount (unsigned int iFakeTriangleCount)
  Call this method to indicate how many fake triangles are in the topology.
unsigned int  QuadIndex (unsigned int iFaceIndex, unsigned int iCornerIndex) const
  Returns the vertex position index of a corner of a quad.
void  SetQuadIndex (unsigned int iFaceIndex, unsigned int iCornerIndex, unsigned int iValue)
  Sets the vertex position index of a corner of a quad.
unsigned int  QuadTCI (unsigned int iFaceIndex, unsigned int iCornerIndex) const
  Returns the vertex texture coordinate index of a corner of a quad.
void  SetQuadTCI (unsigned int iFaceIndex, unsigned int iCornerIndex, unsigned int iValue)
  Sets the vertex texture coordinate index of a corner of a quad.
virtual unsigned int  QuadAdjacency (unsigned int iFaceIndex, unsigned int iSideIndex) const
  Returns the vertex adjacency information index of a side of a quad.
unsigned int  QuadAdjacency_ForcedInline (unsigned int iFaceIndex, unsigned int iSideIndex) const
virtual void  SetQuadAdjacency (unsigned int iFaceIndex, unsigned int iSideIndex, unsigned int iValue)
  Sets the adjacency info for a side of a quad. See QuadAdjacency for details.
bool  HasAdjacentQuad (unsigned int iFaceIndex, unsigned int iSideIndex) const
  Returns true if the given edge of a quad has an adjacent quad on the other side.
unsigned int  TriangleIndex (unsigned int iFaceIndex, unsigned int iCornerIndex) const
  Returns the vertex position index of a corner of a triangle.
void  SetTriangleIndex (unsigned int iFaceIndex, unsigned int iCornerIndex, unsigned int iValue)
  Sets the vertex position index of a corner of a triangle.
unsigned int  TriangleTCI (unsigned int iFaceIndex, unsigned int iCornerIndex) const
  Returns the vertex texture coordinate index of a corner of a triangle.
void  SetTriangleTCI (unsigned int iFaceIndex, unsigned int iCornerIndex, unsigned int iValue)
  Sets the vertex texture coordinate index of a corner of a triangle.
virtual unsigned int  TriangleAdjacency (unsigned int iFaceIndex, unsigned int iSideIndex) const
  Returns the vertex adjacency information index of a side of a triangle.
virtual void  SetTriangleAdjacency (unsigned int iFaceIndex, unsigned int iSideIndex, unsigned int iValue)
  Sets the adjacency info for a side of a triangle. See TriangleAdjacency for details.
bool  HasAdjacentTriangle (unsigned int iFaceIndex, unsigned int iSideIndex) const
  Returns true if the given edge of a triangle has an adjacent triangle on the other side.
unsigned char &  FaceState (unsigned int iFaceIndex)
  Returns the state of a face. See FaceState.
unsigned char  FaceState (unsigned int iFaceIndex) const
  Sets the state of a face.
bool  IsFaceSelected (unsigned int iFaceIndex) const
  Returns true if the given face is selected.
virtual void  SetFaceSelected (unsigned int iFaceIndex, bool bSelected=true, bool bUpdateVertexSelection=false, bool bBatchSelection=false)
  Sets selection state for a face.
bool  IsFaceVisible (unsigned int iFaceIndex) const
  Returns true if the given face is visible.
void  SetFaceVisible (unsigned int iFaceIndex, bool bSelected=true)
  Sets the visibility of a given face.
bool  IsFaceActive (unsigned int iFaceIndex) const
void  SetFaceActive (unsigned int iFaceIndex, bool bSelected=true)
bool  IsFaceMapped (unsigned int iFaceIndex) const
  Used only internally.
void  SetFaceMapped (unsigned int iFaceIndex, bool bSelected=true)
  Used only internally.
bool  IsFakeTriangle (unsigned int iTriangleIndex) const
  This function can only be used for triangular meshes.
void  SetFakeTriangle (unsigned int iTriangleIndex, bool b)
bool  IsFaceTemp (unsigned int iFaceIndex) const
void  SetFaceTemp (unsigned int iFaceIndex, bool bSelected=true)
void  ClearFaceTempStates ()
virtual void  AddFaceComponent (FaceComponent eComponentToAdd)
  Adds new face component(s) to the object.
virtual void  RemoveFaceComponent (FaceComponent eComponentToRemove)
  Removes face component(s) from the object. This might delete some data from the memory.
unsigned int  FaceComponents (void) const
  Returns the current face components for the object.
void  SetFaceCount (unsigned int iFaceCount)
  Sets the number of faces in the object. Existing face data will be kept.
virtual bool  SetAdjacencyCount (unsigned int iCount, bool bKeepContent=true, bool bForced=false)
  Sets the size of the adjacency array.
unsigned int  AdjacencyCount (void) const
  Returns the size of the adjacency matrix.
bool  HasTC (void) const
  Returns true if the mesh has texture coordinates.

Public Attributes

Store< unsigned int >  m_pIndices

Protected Member Functions

  Topology (void)
  Do not use constructors directly. Use CreateInstances() instead.
  Topology (FaceType eType)
  Constructs the object with zero faces.

Friends

class  ::XMesh

Member Enumeration Documentation

enum mudbox::Topology::FaceState
 
Enumeration values:
fsSelected 
fsVisible 
fsFake 
fsActive 
fsMapped 
00052     {
00053         fsSelected = 0x01,
00054         fsVisible = 0x02,
00055         fsFake = 0x04,
00056         fsActive = 0x08,
00057         fsMapped = 0x10,
00058         // fsTemp = 0x20    // for performance reasons, the temp state is split into a seperate vector
00059     };
enum mudbox::Topology::FaceComponent
 
Enumeration values:
fcIndex 
fcAdjacency 
fcTCIndex 
fcNormal 
fcID 
fcOctree 
fcFreeze 
fcState 
00062     {
00063         fcIndex = 1,
00064         fcAdjacency = 2,
00065         fcTCIndex = 4,
00066         fcNormal = 8,
00067         fcID = 16,
00068         fcOctree = 32,
00069         fcFreeze = 64,
00070         fcState = 128
00071     };
enum mudbox::Topology::FaceType
 
Enumeration values:
typeTriangular 
typeQuadric 
00073     {
00074         typeTriangular,
00075         typeQuadric
00076     };

Constructor & Destructor Documentation

mudbox::Topology::Topology void   )  [protected]
 

Do not use constructors directly. Use CreateInstances() instead.

mudbox::Topology::Topology FaceType  eType  )  [protected]
 

Constructs the object with zero faces.


Member Function Documentation

void mudbox::Topology::MoveTo Topology pDestination  ) 
 

This object will loose all data and become an empty topology.

void mudbox::Topology::CopyTo Topology pDestination  )  const
 

This function is similar to MoveTo, but since it is copying all the data, it is slower.

You can use this function when you want to do some temporary change to a mesh (like you want to change the vertex ordering inside faces) but then you want to restore the original state. In that case you can simply create a copy of the mesh, do the modifications, and when you don't need it any longer, just delete it.

void mudbox::Topology::Serialize Stream s  )  [virtual]
 

serializes the content of the object into/from a stream.

Reimplemented from mudbox::TreeNode.

FaceType mudbox::Topology::Type void   )  const [inline]
 

Returns the type of the topology. Can be full triangular or full quadric.

00115 { return m_eType; };
void mudbox::Topology::SetType FaceType  eType  ) 
 

Sets the type of the object. This call also clears all the content of the object.

int mudbox::Topology::SideCount void   )  const [inline]
 

Returns the number of sides in the faces. This is three if the topology is triangle based, and four if its quad based.

00119 { return Type() == typeTriangular ? 3 : 4; };
unsigned int mudbox::Topology::FaceCount void   )  const [inline]
 

Returns the number of faces in the topology.

00123 { return m_iFaceCount; };
virtual Vector mudbox::Topology::FaceNormal unsigned int  iFaceIndex  )  const [virtual]
 

Returns the normal vector for a face in the topology.

void mudbox::Topology::SetFaceID unsigned int  iFaceIndex,
unsigned int  iID
[inline]
 

This function is used only internally.

00127 { m_pFaceIDs[iFaceIndex] = iID; };
unsigned int mudbox::Topology::FaceID unsigned int  iFaceIndex  )  const [inline]
 

This function is used only internally.

00129 { return m_pFaceIDs[iFaceIndex]; };
virtual void mudbox::Topology::SetFakeTriangleCount unsigned int  iFakeTriangleCount  )  [virtual]
 

Call this method to indicate how many fake triangles are in the topology.

Call SetFaceCount before calling this method. Note this has no effect on quadric meshes.

unsigned int mudbox::Topology::QuadIndex unsigned int  iFaceIndex,
unsigned int  iCornerIndex
const [inline]
 

Returns the vertex position index of a corner of a quad.

The value returned by this call can be used as a patameter for the VertexPosition() function in class Mesh.

00137 { return m_pIndices[iFaceIndex*4+iCornerIndex]; };
void mudbox::Topology::SetQuadIndex unsigned int  iFaceIndex,
unsigned int  iCornerIndex,
unsigned int  iValue
[inline]
 

Sets the vertex position index of a corner of a quad.

The value returned by this call can be used as parameter for the VertexTC() function in class Mesh.

00140 { m_pIndices[iFaceIndex*4+iCornerIndex] = iValue; };
unsigned int mudbox::Topology::QuadTCI unsigned int  iFaceIndex,
unsigned int  iCornerIndex
const [inline]
 

Returns the vertex texture coordinate index of a corner of a quad.

00142 { return m_pTCI[iFaceIndex*4+iCornerIndex]; }
void mudbox::Topology::SetQuadTCI unsigned int  iFaceIndex,
unsigned int  iCornerIndex,
unsigned int  iValue
[inline]
 

Sets the vertex texture coordinate index of a corner of a quad.

00144 { m_pTCI[iFaceIndex*4+iCornerIndex] = iValue; }
virtual unsigned int mudbox::Topology::QuadAdjacency unsigned int  iFaceIndex,
unsigned int  iSideIndex
const [inline, virtual]
 

Returns the vertex adjacency information index of a side of a quad.

If the returned value is x, then x/4 is the index of the adjacent quad, while x%4 is the side in the adjacent quad which is common with the given one.

00148 { return m_pAdjacency[iFaceIndex*4+iSideIndex]; }
unsigned int mudbox::Topology::QuadAdjacency_ForcedInline unsigned int  iFaceIndex,
unsigned int  iSideIndex
const [inline]
 
00149 { return m_pAdjacency[iFaceIndex*4+iSideIndex]; }
virtual void mudbox::Topology::SetQuadAdjacency unsigned int  iFaceIndex,
unsigned int  iSideIndex,
unsigned int  iValue
[inline, virtual]
 

Sets the adjacency info for a side of a quad. See QuadAdjacency for details.

00152         { m_pAdjacency[iFaceIndex*4+iSideIndex] = iValue; }
bool mudbox::Topology::HasAdjacentQuad unsigned int  iFaceIndex,
unsigned int  iSideIndex
const [inline]
 

Returns true if the given edge of a quad has an adjacent quad on the other side.

00154 { return QuadAdjacency( iFaceIndex, iSideIndex ) < 0x80000000; };
unsigned int mudbox::Topology::TriangleIndex unsigned int  iFaceIndex,
unsigned int  iCornerIndex
const [inline]
 

Returns the vertex position index of a corner of a triangle.

The value returned by this call can be used as a patameter for the VertexPosition() function in class Mesh.

00159 { return m_pIndices[iFaceIndex*3+iCornerIndex]; };
void mudbox::Topology::SetTriangleIndex unsigned int  iFaceIndex,
unsigned int  iCornerIndex,
unsigned int  iValue
[inline]
 

Sets the vertex position index of a corner of a triangle.

00161 { m_pIndices[iFaceIndex*3+iCornerIndex] = iValue; };
unsigned int mudbox::Topology::TriangleTCI unsigned int  iFaceIndex,
unsigned int  iCornerIndex
const [inline]
 

Returns the vertex texture coordinate index of a corner of a triangle.

00163 { return m_pTCI[iFaceIndex*3+iCornerIndex]; }
void mudbox::Topology::SetTriangleTCI unsigned int  iFaceIndex,
unsigned int  iCornerIndex,
unsigned int  iValue
[inline]
 

Sets the vertex texture coordinate index of a corner of a triangle.

The value returned by this call can be used as parameter for the VertexTC() function in class Mesh.

00166 { m_pTCI[iFaceIndex*3+iCornerIndex] = iValue; }
virtual unsigned int mudbox::Topology::TriangleAdjacency unsigned int  iFaceIndex,
unsigned int  iSideIndex
const [inline, virtual]
 

Returns the vertex adjacency information index of a side of a triangle.

If the returned value is x, then x/3 is the index of the adjacent triangle, while x%3 is the side in the adjacent triangle which is common with the given one.

00170 { return m_pAdjacency[iFaceIndex*3+iSideIndex]; }
virtual void mudbox::Topology::SetTriangleAdjacency unsigned int  iFaceIndex,
unsigned int  iSideIndex,
unsigned int  iValue
[inline, virtual]
 

Sets the adjacency info for a side of a triangle. See TriangleAdjacency for details.

00173         { m_pAdjacency[iFaceIndex*3+iSideIndex] = iValue; }
bool mudbox::Topology::HasAdjacentTriangle unsigned int  iFaceIndex,
unsigned int  iSideIndex
const [inline]
 

Returns true if the given edge of a triangle has an adjacent triangle on the other side.

00176         { return TriangleAdjacency( iFaceIndex, iSideIndex ) < 0x80000000; };
unsigned char& mudbox::Topology::FaceState unsigned int  iFaceIndex  )  [inline]
 

Returns the state of a face. See FaceState.

00179 { return m_pFaceState[iFaceIndex]; };
unsigned char mudbox::Topology::FaceState unsigned int  iFaceIndex  )  const [inline]
 

Sets the state of a face.

00181 { return m_pFaceState[iFaceIndex]; };
bool mudbox::Topology::IsFaceSelected unsigned int  iFaceIndex  )  const [inline]
 

Returns true if the given face is selected.

00184 { return (FaceState( iFaceIndex ) & fsSelected) != 0; };
virtual void mudbox::Topology::SetFaceSelected unsigned int  iFaceIndex,
bool  bSelected = true,
bool  bUpdateVertexSelection = false,
bool  bBatchSelection = false
[virtual]
 

Sets selection state for a face.

The parameter bUpdateVertexSelection controls if the internal buffers should be updated or not. Passing true as this parameter makes the function slow, so do that only if you want to change the selection status for a few faces only. Otherwise use false, and after you changed all the vertices, update the buffers once only. [HOW? OPEN QUESTION]

bool mudbox::Topology::IsFaceVisible unsigned int  iFaceIndex  )  const [inline]
 

Returns true if the given face is visible.

00191 { return (FaceState( iFaceIndex ) & fsVisible) != 0; };
void mudbox::Topology::SetFaceVisible unsigned int  iFaceIndex,
bool  bSelected = true
[inline]
 

Sets the visibility of a given face.

00194         { if ( bSelected ) FaceState( iFaceIndex ) |= fsVisible; else FaceState( iFaceIndex ) &= 0xff-fsVisible; };
bool mudbox::Topology::IsFaceActive unsigned int  iFaceIndex  )  const [inline]
 
00195 { return (FaceState( iFaceIndex ) & fsActive) != 0; };
void mudbox::Topology::SetFaceActive unsigned int  iFaceIndex,
bool  bSelected = true
[inline]
 
00197         { if ( bSelected ) FaceState( iFaceIndex ) |= fsActive; else FaceState( iFaceIndex ) &= 0xff-fsActive; };
bool mudbox::Topology::IsFaceMapped unsigned int  iFaceIndex  )  const [inline]
 

Used only internally.

00199 { return (FaceState( iFaceIndex ) & fsMapped) != 0; };
void mudbox::Topology::SetFaceMapped unsigned int  iFaceIndex,
bool  bSelected = true
[inline]
 

Used only internally.

00202         { if ( bSelected ) FaceState( iFaceIndex ) |= fsMapped; else FaceState( iFaceIndex ) &= 0xff-fsMapped; };
bool mudbox::Topology::IsFakeTriangle unsigned int  iTriangleIndex  )  const [inline]
 

This function can only be used for triangular meshes.

If the mesh only contains triangles, then this function always return false. When the original mesh was a mixed tri-quad or n-sided one, then during import it gets converted into a triangular mesh. Each polygon which has more than tree sides are converted into N-2 triangles where N is the number of sides in the polygon. The first triangle is marked as real, but the other ones are marked as fake by this function. So this function makes it possible to restore the original polygon structure of the mesh.

00210         { return iTriangleIndex < FaceCount() && (FaceState( iTriangleIndex ) & fsFake); };
void mudbox::Topology::SetFakeTriangle unsigned int  iTriangleIndex,
bool  b
[inline]
 
00212         { if( iTriangleIndex < FaceCount() ) { 
00213             if ( b ) FaceState( iTriangleIndex ) |= fsFake; 
00214             else     FaceState( iTriangleIndex ) &= 0xff-fsFake; 
00215           }; 
00216         };
bool mudbox::Topology::IsFaceTemp unsigned int  iFaceIndex  )  const [inline]
 
00218 { return m_pFaceTemp[iFaceIndex]; };
void mudbox::Topology::SetFaceTemp unsigned int  iFaceIndex,
bool  bSelected = true
[inline]
 
00220         { m_pFaceTemp[iFaceIndex] = bSelected; }
void mudbox::Topology::ClearFaceTempStates  )  [inline]
 
00224     {
00225         MB_ASSERT(m_iFaceCount <= m_pFaceTemp.ItemCount()); 
00226         memset(&m_pFaceTemp[0], 0, m_iFaceCount);  // memset is the fastest way to clear the array.
00227     }
virtual void mudbox::Topology::AddFaceComponent FaceComponent  eComponentToAdd  )  [virtual]
 

Adds new face component(s) to the object.

If the specified components did not exist yet, memory will be allocated for them.

virtual void mudbox::Topology::RemoveFaceComponent FaceComponent  eComponentToRemove  )  [virtual]
 

Removes face component(s) from the object. This might delete some data from the memory.

unsigned int mudbox::Topology::FaceComponents void   )  const [inline]
 

Returns the current face components for the object.

00236 { return m_eFaceComponents; };
void mudbox::Topology::SetFaceCount unsigned int  iFaceCount  ) 
 

Sets the number of faces in the object. Existing face data will be kept.

virtual bool mudbox::Topology::SetAdjacencyCount unsigned int  iCount,
bool  bKeepContent = true,
bool  bForced = false
[virtual]
 

Sets the size of the adjacency array.

unsigned int mudbox::Topology::AdjacencyCount void   )  const [inline]
 

Returns the size of the adjacency matrix.

00242 { return m_pAdjacency.ItemCount(); };
bool mudbox::Topology::HasTC void   )  const [inline]
 

Returns true if the mesh has texture coordinates.

00245 { return (FaceComponents() & fcTCIndex) != 0; };

Friends And Related Function Documentation

friend class ::XMesh [friend]
 

Member Data Documentation

Store<unsigned int> mudbox::Topology::m_pIndices
 

mudbox::Topology mudbox::Topology mudbox::Topology mudbox::Topology mudbox::Topology mudbox::Topology mudbox::Topology mudbox::Topology mudbox::Topology mudbox::Topology
mudbox::Topology mudbox::Topology mudbox::Topology mudbox::Topology mudbox::Topology mudbox::Topology mudbox::Topology mudbox::Topology mudbox::Topology mudbox::Topology